home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C++ / Applications / PICSee Dust 1.01 / Quaternary Source / GraphicsBuffers.h < prev    next >
Text File  |  1995-11-24  |  8KB  |  313 lines

  1. /*
  2.     GraphicsBuffer.h header file
  3.     by Hiep Dam
  4.     Version 4.0
  5.     Last update: Nov 1995
  6.     
  7.     Copyright ©1995 by Hiep Dam, All Rights Reserved
  8.     You may freely use the GraphicsBuffers source files
  9.     in your own applications.
  10.     
  11.     This header file is cross-platform compatible. You may use this same
  12.     header file for all the supported platforms (currently only Macintosh).
  13. */
  14.  
  15.  
  16. // ===========================================================================
  17.  
  18.  
  19. #ifndef GRAPHICSBUFFERS_H_
  20. #define GRAPHICSBUFFERS_H_
  21.  
  22. #ifndef CP_DATA_H_
  23.     #include "CP_Data.h"
  24. #endif
  25.  
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29.  
  30.  
  31. // ===========================================================================
  32.  
  33.  
  34. /*
  35.     These are the pixel copying routines currently supported by
  36.     GraphicsBuffers.
  37. */
  38.  
  39. enum {
  40.     kPixelCopyRectMethod,            // No mask used.
  41.     kPixelCopyMaskMethod,            // A 1-bit B&W mask is used.
  42.     kPixelCopyTransparentMethod,    // Transparent color as "mask", no real mask.
  43.     kPixelCopyRegionMethod,            // Region as a mask.
  44.  
  45.     kBlitterRectMethod,
  46.     kBlitterTransparentMethod,
  47.     kBlitterDeepMaskMethod            // Mask same depth as src buffer.
  48. };
  49.  
  50.  
  51. // ---------------------------------------------------------------------------
  52.  
  53. // GraphicsBuffers types
  54. enum {
  55.     kGraphicsBuffer,
  56.     kVideoMemoryBuffer        // A graphics buffer equivalent for the monitor
  57. };
  58.  
  59. // GraphicsBuffers flags (used in NewGraphicsBuffer, UpdateGraphicsBuffer, etc)
  60. enum {
  61.     kGBOptimalFlag = 0
  62. };
  63.  
  64. // ---------------------------------------------------------------------------
  65.  
  66. typedef short GBErr;
  67.  
  68.  
  69. // Supported error codes
  70. enum {
  71.     kGBNoErr = 0,
  72.     
  73.     kGBNoMemAvailErr = 1972,
  74.     kGBParamErr,
  75.     kGBOSErr                    // Error from operating system
  76. };
  77.  
  78. // ---------------------------------------------------------------------------
  79.  
  80. /*
  81.     The GraphicsBuffer structure is now private and internal to the
  82.     specific implementations of GraphicsBuffers. The GraphicsBufferPtr
  83.     is an opaque pointer; you should not dereference it.
  84. */
  85.  
  86. typedef void *GraphicsBufferPtr;
  87.  
  88. /*
  89.     GraphicsEnvironment.
  90.     The fields are private and not to be handled directly, but are
  91.     declared here like this so the compiler knows the size of
  92.     the GraphicsEnvironment structure.
  93. */
  94. typedef struct {
  95.     void *reserved0;
  96.     void *reserved1;
  97. } GraphicsEnvironment, *GraphicsEnvPtr;
  98.  
  99. /*
  100.     These defines are most useful if you use double-buffering animation
  101.     in your programs. There are three distince steps in double-buffering,
  102.     and the function pointers here define those steps.
  103.  
  104.     ImageEraser    -> Copy bkgnd patch & put it onto temp buffer
  105.     ImageDrawer    -> Draw sprite (masked) over bkgnd patch in temp buffer
  106.  
  107.         Depending on the drawer, typecasted MaskPtr could be either a
  108.         RgnHandle (Macintosh) or a GraphicsBufferPtr
  109.     ImageRefresher -> Copy this updated patch from temp buffer to screen
  110. */
  111.  
  112. typedef void *MaskPtr;    // Macintosh: either a RgnHandle or a GraphicsBufferPtr
  113.                         // Windows: either a HRGN or a GraphicsBufferPtr
  114.  
  115. typedef void (*ImageEraser)(GraphicsBufferPtr, GraphicsBufferPtr,
  116.                             const CP_Rect*, const CP_Rect*);
  117.  
  118. typedef void (*ImageDrawer)(GraphicsBufferPtr, GraphicsBufferPtr,
  119.                             const CP_Rect*, const CP_Rect*, MaskPtr);
  120.  
  121. typedef ImageEraser ImageRefresher;
  122.  
  123.  
  124. // ===========================================================================
  125.  
  126.  
  127. /*
  128.     Make sure you call InitGraphicsBuffer() before calling any other
  129.     routines in here!
  130. */
  131.  
  132. GBErr InitGraphicsBuffers();
  133.  
  134.  
  135. /*
  136.     GraphicsBuffer creation, deletion, utility calls. Most of these
  137.     are fashioned after similar GWorld (Macintosh) calls.
  138. */
  139.  
  140. GBErr NewGraphicsBuffer(
  141.     GraphicsBufferPtr    *buffer,
  142.     CP_ULong            pixelDepth,
  143.     const CP_Rect        *boundsRect,
  144.     CP_ULong            flags,
  145.     CP_ULong            cache);
  146.  
  147. GBErr UpdateGraphicsBuffer(
  148.     GraphicsBufferPtr    buffer,
  149.     long                pixelDepth,
  150.     const CP_Rect        *boundsRect,
  151.     long                flags,
  152.     long                cache);
  153.  
  154. GBErr DisposeGraphicsBuffer(GraphicsBufferPtr buffer);
  155.  
  156. GBErr Convert2GraphicsBuffer(
  157.     GraphicsBufferPtr    *buffer,
  158.     CP_Window_Ref        srcWind,
  159.     const CP_Rect        *bounds,
  160.     long                cache);
  161.  
  162. void SetGraphicsBuffer(const GraphicsBufferPtr buffer);
  163. void SetGraphicsEnvironment(const GraphicsEnvPtr environs);
  164. void GetGraphicsEnvironment(GraphicsEnvPtr environs);
  165.  
  166. Boolean LockGraphicsBuffer(const GraphicsBufferPtr buffer);
  167. void UnlockGraphicsBuffer(const GraphicsBufferPtr buffer);
  168.  
  169. // ---------------------------------------------------------------------------
  170.  
  171. // Get/Set Routines
  172.  
  173. long GetGraphicsBufferType(GraphicsBufferPtr buffer);
  174. long GetGraphicsBufferDepth(GraphicsBufferPtr buffer);
  175. void *GetGraphicsBufferPixelAddress(GraphicsBufferPtr buffer);
  176. unsigned long GetGraphicsBufferRowBytes(GraphicsBufferPtr buffer);
  177. void GetGraphicsBufferBounds(GraphicsBufferPtr buffer, CP_Rect *globalBounds);
  178.  
  179. void SetGraphicsBufferTransferMode(short newMode);
  180. short GetGraphicsBufferTransferMode();
  181.  
  182. #ifdef __Macintosh_Platform__
  183. #ifndef __QDOFFSCREEN__
  184.     #include <QDOffscreen.h>
  185. #endif
  186. GWorldPtr GetGraphicsBufferGWorld(GraphicsBufferPtr buffer);
  187. #endif
  188.  
  189. // ---------------------------------------------------------------------------
  190.  
  191. /*
  192.     Pixel copying calls.
  193. */
  194.  
  195.     // Uses standard operating system calls (Macintosh-> CopyBits)
  196.     // Uses kPixelCopyRectMethod
  197. void CopyGraphicsBuffer(
  198.     GraphicsBufferPtr    srcBuffer,
  199.     GraphicsBufferPtr    destBuffer,
  200.     const CP_Rect        *srcR,
  201.     const CP_Rect        *destR);
  202.  
  203.     // Explicit source or destination.
  204.     // Uses kPixelCopyRectMethod
  205. void CopyGraphicsBuffer2Window(
  206.     GraphicsBufferPtr    srcBuffer,
  207.     CP_Window_Ref        destWind,
  208.     const CP_Rect        *srcR,
  209.     const CP_Rect        *destR);
  210.  
  211.     // Uses kPixelCopyRectMethod
  212. void CopyWindow2GraphicsBuffer(
  213.     CP_Window_Ref        srcWind,
  214.     GraphicsBufferPtr    destBuffer,
  215.     const CP_Rect        *srcR,
  216.     const CP_Rect        *destR);
  217.  
  218.     // Uses kPixelCopyRegionMethod
  219. void CopyGraphicsBufferRegion(
  220.     GraphicsBufferPtr    srcBuffer,
  221.     GraphicsBufferPtr    destBuffer,
  222.     const CP_Rect        *srcR,
  223.     const CP_Rect        *destR,
  224.     CP_Region_Hdl        maskRgn);
  225.  
  226.     // Uses kPixelCopyMaskMethod
  227. void CopyGraphicsBufferMask(
  228.     GraphicsBufferPtr    srcBuffer,
  229.     GraphicsBufferPtr    destBuffer,
  230.     const CP_Rect        *srcR,
  231.     const CP_Rect        *destR,
  232.     GraphicsBufferPtr    maskBuffer);
  233.  
  234.     // Uses kPixelCopyTransparentMethod
  235. void CopyGraphicsBufferTransparent(
  236.     GraphicsBufferPtr    srcBuffer,
  237.     GraphicsBufferPtr    destBuffer,
  238.     const CP_Rect        *srcR,
  239.     const CP_Rect        *destR,
  240.     GraphicsBufferPtr    _notUsed);
  241.  
  242. // ---------------------------------------------------------------------------
  243.  
  244. // Uses custom pixel-blitting routines (8-bit only)
  245.  
  246.     // Uses kBlitterRectMethod
  247. void BlitGraphicsBuffer_8bit(
  248.     GraphicsBufferPtr    srcBuffer,
  249.     GraphicsBufferPtr    destBuffer,
  250.     const CP_Rect        *srcR,
  251.     const CP_Rect        *destR);
  252.  
  253.     // Uses kBlitterDeepMaskMethod
  254. void BlitGraphicsBuffer_Mask8bit(
  255.     GraphicsBufferPtr    srcBuffer,
  256.     GraphicsBufferPtr    destBuffer,
  257.     const CP_Rect        *srcR,
  258.     const CP_Rect        *destR,
  259.     GraphicsBufferPtr    maskBuffer);
  260.  
  261.     // Uses kBlitterTransparentMethod
  262. void BlitGraphicsBuffer_Transparent8bit(
  263.     GraphicsBufferPtr    srcBuffer,
  264.     GraphicsBufferPtr    destBuffer,
  265.     const CP_Rect        *srcR,
  266.     const CP_Rect        *destR,
  267.     GraphicsBufferPtr    _notUsed);
  268.  
  269.  
  270.  
  271. // 4-bit blitters
  272.  
  273.     // Uses kBlitterRectMethod
  274. void BlitGraphicsBuffer_4bit(
  275.     GraphicsBufferPtr    srcBuffer,
  276.     GraphicsBufferPtr    destBuffer,
  277.     const CP_Rect        *srcR,
  278.     const CP_Rect        *destR);
  279.  
  280.     // Uses kBlitterDeepMaskMethod
  281. void BlitGraphicsBuffer_Mask4bit(
  282.     GraphicsBufferPtr    srcBuffer,
  283.     GraphicsBufferPtr    destBuffer,
  284.     const CP_Rect        *srcR,
  285.     const CP_Rect        *destR,
  286.     GraphicsBufferPtr    maskBuffer);
  287.  
  288.  
  289.  
  290. // 16-bit blitters
  291.  
  292.     // Uses kBlitterRectMethod
  293. void BlitGraphicsBuffer_16bit(
  294.     GraphicsBufferPtr    srcBuffer,
  295.     GraphicsBufferPtr    destBuffer,
  296.     const CP_Rect        *srcR,
  297.     const CP_Rect        *destR);
  298.  
  299.     // Uses kBlitterTransparentMethod
  300. void BlitGraphicsBuffer_Transparent16bit(
  301.     GraphicsBufferPtr    srcBuffer,
  302.     GraphicsBufferPtr    destBuffer,
  303.     const CP_Rect        *srcR,
  304.     const CP_Rect        *destR,
  305.     GraphicsBufferPtr    _notUsed);
  306.  
  307. // ===========================================================================
  308.  
  309. #ifdef __cplusplus
  310. }
  311. #endif // __cplusplus
  312.  
  313. #endif // GRAPHICSBUFFERS_H_